home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Tech Arsenal 1
/
Tech Arsenal (Arsenal Computer).ISO
/
tek-04
/
lyapunba.zip
/
LYAPX12I.BAS
< prev
next >
Wrap
BASIC Source File
|
1991-09-23
|
2KB
|
77 lines
DEFINT I-N: DIM rxy(0 TO 1): CLS ' set screen defaults
SCREEN 12: CLS : INPUT ; "? default=1"; z: CLS : INPUT ; "-x1 ? default=2"; xz: CLS : INPUT ; "x2 ?-default=4"; xzz: CLS
INPUT ; "-y1 ?default=2"; yz: CLS : INPUT ; "y2 ?default=4"; yzz: CLS
' set parameter ranges:
' niter = the number of iterations
' x1, x2 = limits of "b" range
' y1, y2 = limits of "a" range
' nx, ny = number of pixels
' xmax = maximum allowed size of iterate, to avoid overflows
x1 = -xz: x2 = xzz: y1 = -yz: y2 = yzz
nx = 640: ny = 480: NITER = 256: xmax = 1D+16
' start iteration with x = x0 = critical point
x0 = .5
' determine pixel steps
dx = (x2 - x1) / nx: dy = (y2 - y1) / ny
' start iterating
FOR j = 0 TO ny
' rxy(0) represents "b" in the "ab" periodic forcing
rxy(0) = dy * j + y1
FOR i = 0 TO nx
' rxy(1) represents "a" in the "ab" forcing
rxy(1) = dx * i + x1
x = x0
' iterate niter times to remove transients
FOR ITER = z TO NITER: ' if l = 1, use "a"; if l = 0, use "b"
l = ITER MOD 2
x = x * rxy(l) * (1 - x)
' color divergent points with color #1
IF ABS(x) > xmax THEN k = 1: x = x0: GOTO colorpix
NEXT ITER
' iterate niter times to compute exponent, stored in al
al = 0
FOR ITER = z TO NITER
l = ITER MOD 2: x = x * rxy(l) * (1 - x)
IF ABS(x) > xmax THEN k = 1: x = x0: GOTO colorpix
' d = ABS(the derivative of the function, with respect to x)
d = ABS(rxy(l) * (1 - 2 * x))
' avoid trying to find LOG(0)
IF d = 0 THEN d = 1E-10
' add LOG(d) to the running total for al;
' since I will scale al to determine a color mapping scheme, I
' don't need to divide d by LOG(2), as in the SA article
al = al + LOG(d)
' only color points with negative exponents (periodic orbits)
' change this IF-THEN-ELSE block to show positive exponents (chaotic)
IF al > 0# THEN
k = 0
ELSE
' at this point, use any scale factors you wish to get a nice
' distribution of colors
al = al / (NITER)
k = ((-al * 1000#) MOD 255) + 1
END IF
colorpix: PSET (i, j), k
NEXT
NEXT
NEXT
' loop until a key is pressed
WHILE INKEY$ = "": WEND
ENDd: GOTO ENDd